#include <iostream>
#include <memory>
class Girl;
class Boy
{
public:
    Boy()
    {
        std::cout<<"Boy构造函数"<<std::endl;
    }
    ~Boy()
    {
        std::cout<<"Boy析构函数"<<std::endl;
    }
    void SetGirlFriend(std::shared_ptr<Girl>& girlFreind)
    {
        this->girlFriend = girlFreind;
    }
private:
    std::shared_ptr<Girl> girlFriend;
};

class Girl
{
public:
    Girl()
    {
        std::cout<<"Girl构造函数"<<std::endl;
    }
    ~Girl()
    {
        std::cout<<"Girl析构函数"<<std::endl;
    }
    void SetBoyFriend(std::shared_ptr<Boy>& boyFriend)
    {
        this->boyFriend = boyFriend;
    }
private:
    std::weak_ptr<Boy> boyFriend;
};

int main()
{
    std::shared_ptr<Boy> b(new Boy);
    std::shared_ptr<Girl> g(new Girl);
    b->SetGirlFriend(g);
    g->SetBoyFriend(b);

    std::cout<<b.use_count()<<std::endl;
    std::cout<<g.use_count()<<std::endl;
    return 0;
}